var express = require('express');
var router = express.Router();

const { uploadFiles } = require('../utils/handleFiles.js')

router.post('/upLoadImages', function (req, res, next) {
   const uploadImages = uploadFiles({
        path: './public/temp',//设置上传成功后的图片存储的路径
        key: 'file',
        size: 8000

    })
    uploadImages(req,res,error =>{
        if(error){
            console.log('图片上传失败',error);
        }else{
            console.log('图片上传成功',req.files);
            res.send({
                message:'图片上传成功',
                code: 1,
                result: 'temp/'+ req.files[0].filename
            })
        }
    })
});

module.exports = router;